<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\BaseSite;
use ms\modules\article\models\ArticleInfo;
/* @var $this yii\web\View */
/* @var $model ms\modules\article\models\ArticleSite */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="article-site-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'article_id')->textInput() ?>
    
    <!-- 站点 -->
     <span>发布站点</span>
		<?php foreach (BaseSite::getAllSite(1) as $key=>$valu){?>
		<input name='site_id[]' value='<?=$key?>' class='' type='checkbox'><?=$valu?>
		<?php }?>
	<?php if($model->isNewRecord ){?>
	<br/>
	<br/>
	<br/>
	<input type="button" value="全选" class="btn btn-success" style="padding:1px;"  id="choseAll"/>&nbsp;&nbsp;&nbsp;
	<input type="button" value="全不选" class="btn btn-success" style="padding:1px;"  id="delAll"/>&nbsp;&nbsp;&nbsp;
	<input type="button" value="反选" class="btn btn-success" style="padding:1px;"  id="fanAll"/>
	<br/>
	<br/>
	<?php }?>
	 <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>
</div>
<style>
.form-control{width:350px;}
</style>
<script>
	 $("#choseAll").click(function(){
		  $("input[name='site_id[]']").each(function(){
			  this.checked = true;
		  });
	 });
	//取消选择
	 $("#delAll").click(function(){
		  $("input[name='site_id[]']").each(function(){
			  this.checked = false;
		  });
	 });
	 $("#fanAll").click(function(){
		  $("input[name='site_id[]']").each(function(){
			  if(this.checked == false){
				  	this.checked = true;
				}else{
					this.checked = false;
				}
		  });
	 });
</script>
